home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / oocs / modgloba.bas < prev    next >
BASIC Source File  |  1999-09-06  |  3KB  |  139 lines

  1. Attribute VB_Name = "modGlobals"
  2. Option Explicit
  3.  
  4.  
  5. ' API Declres
  6. Public Declare Function GetTickCount Lib "kernel32" () As Long
  7.  
  8.  
  9. '--- Globals
  10. Public Client_ As cClientActions
  11. Public bReplied As Boolean
  12. Public lTIme As Long
  13.  
  14.  
  15.  
  16. '--- This is the Start-Up Procedure
  17. Sub Main()
  18.    ' create the Client_ Object for use through out the application
  19.    ' which will handle all winsock capabilities.
  20.    Set Client_ = New cClientActions
  21.        
  22.    bReplied = False
  23.    frmCLient.Show
  24. End Sub
  25.  
  26.  
  27.  
  28. '--- SendData() This function merely sends the data to the Server and handles
  29. '--- it's own Errors.
  30. Function SendData(sData As String) As Boolean
  31.     On Error GoTo ErrH
  32.     Dim TimeOut As Long
  33.     
  34.     
  35.     bReplied = False
  36.     frmCLient.tcpClient.SendData sData
  37.     Do Until (frmCLient.tcpClient.State = 0) Or (TimeOut < 10000)
  38.         DoEvents
  39.         TimeOut = TimeOut + 1
  40.         If TimeOut > 10000 Then Exit Do
  41.     Loop
  42.     SendData = True
  43.     Exit Function
  44.     
  45. ErrH:
  46.     SendData = False
  47.     MsgBox Err.Description, 16, "Error #" & Err.Number
  48.     DoCntrls False
  49.     frmCLient.mnuConnect.Enabled = True
  50.     FileCount False
  51.     StatusReport " Dissconnected!"
  52.     Exit Function
  53.     
  54. End Function
  55.  
  56. ' --- updates a label
  57. Sub StatusReport(sMsg As String)
  58.    frmCLient.lblCurCaption = sMsg
  59. End Sub
  60.  
  61.  
  62. Sub UpdateListBox(LstBox As Control, sAddThese As String)
  63.     Dim lStartPos As Long, SubStr As String
  64.     
  65.       'The File Paths will be seperated by ";", so extract them
  66.       'one by one and add to the combo box of choice
  67.       lStartPos = InStr(1, sAddThese, ";")
  68.       While lStartPos > 0
  69.           SubStr = Mid$(sAddThese, 1, lStartPos - 1)
  70.           sAddThese = Mid$(sAddThese, lStartPos + 1)
  71.           lStartPos = InStr(1, sAddThese, ";")
  72.           LstBox.AddItem SubStr
  73.       Wend
  74.       
  75.     
  76. End Sub
  77.  
  78.  
  79.  
  80. ' --- a function for pausing
  81.  
  82. Sub Pause(HowLong As Long)
  83.     Dim u%, tick As Long
  84.     tick = GetTickCount
  85.     
  86.     Do
  87.       u% = DoEvents
  88.     Loop Until tick + HowLong < GetTickCount
  89. End Sub
  90.  
  91.  
  92. ' --- update the file count label
  93. Sub FileCount(ShowIt As Boolean)
  94.   
  95.   With frmCLient.lblFileCnt
  96.     If ShowIt Then
  97.      .Visible = True
  98.     Else
  99.      .Visible = False
  100.     End If
  101.      .Caption = Client_.NumFiles & " file(s) on the " & Client_.CurDrive & " Drive."
  102.   End With
  103.   
  104. End Sub
  105.  
  106.  
  107. '  --- Enables and disables the controls
  108.  
  109. Sub DoCntrls(CntrlState As Boolean)
  110.    With frmCLient
  111.       .cmdMsg.Enabled = CntrlState
  112.       .cmdRetrieve.Enabled = CntrlState
  113.       .cmdSysInfo.Enabled = CntrlState
  114.       .lblCap.Enabled = CntrlState
  115.    End With
  116. End Sub
  117.  
  118.  
  119. Public Sub DisplayInfo(sAddThese)
  120.       Dim lStartPos As Long, SubStr As String
  121.       Dim SysData(1 To 10) As String
  122.       Dim SysDirs(1 To 3) As String
  123.       Dim TempStor(1 To 9) As String
  124.       Dim xx As Integer
  125.       frmCLient.Picture1.Visible = True
  126.       'The File Paths will be seperated by ";", so extract them
  127.       'one by one and add to the combo box of choice
  128.       lStartPos = InStr(1, sAddThese, ";")
  129.       While lStartPos > 0
  130.           xx = xx + 1
  131.           SubStr = Mid$(sAddThese, 1, lStartPos - 1)
  132.           sAddThese = Mid$(sAddThese, lStartPos + 1)
  133.           lStartPos = InStr(1, sAddThese, ";")
  134.           frmCLient.Label(xx - 1) = SubStr
  135.       Wend
  136.       
  137.       
  138. End Sub
  139.